package com.hliu.shiro.model;

import com.hliu.core.model.BaseModel;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * author: 6
 * date: 13-4-18
 */
@Entity
@Table(name = "fc_user")
public class User extends BaseModel {
	private String username;
	private String password;
	private List<Role> roles;

	@Column(name = "username")
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@ManyToMany(targetEntity = Role.class)
	@JoinTable(name = "fc_user_role",
			joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
			inverseJoinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")})
	public List<Role> getRoles() {
		if (roles == null) {
			roles = new ArrayList();
		}
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
}
